package com.xmy.cultivate.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.xmy.cultivate.entity.Subjects;
import com.xmy.cultivate.mapper.SubjectsMapper;
import com.xmy.cultivate.service.ISubjectsService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 科目 服务实现类
 * </p>
 *
 * @author min
 * @since 2022-07-26
 */
@Service
public class SubjectsServiceImpl extends ServiceImpl<SubjectsMapper, Subjects> implements ISubjectsService {

    /**
     * 获取成绩填写科目
     * @param yearPart
     * @param quarterNum
     * @return
     */
    @Override
    public List<Subjects> getTranscriptSubjects(Integer yearPart, Integer quarterNum, Integer yearClassId,Integer examNum){
        QueryWrapper<Subjects> subjectsQueryWrapper = new QueryWrapper<>();
        if (yearClassId ==0){
            //幼儿园，是不需要填写成绩的，排除
            subjectsQueryWrapper.in("id",0);
        }else if (yearClassId == 1){
            if ((quarterNum == 2 || quarterNum == 1) || examNum == 1){
                subjectsQueryWrapper.in("id",2,4);
            }else {
                subjectsQueryWrapper.in("id",0);
            }
        }else if (yearClassId == 2){
            subjectsQueryWrapper.in("id",2,4);
        }else if (yearClassId ==3){
            if ((quarterNum == 2 || quarterNum == 1) || examNum == 1){
                subjectsQueryWrapper.in("id",1,2,4);
            }else {
                subjectsQueryWrapper.in("id",2,4);
            }
        }else if (yearClassId>3 && yearClassId<=6){
            subjectsQueryWrapper.in("id",1,2,4);
        }else if (yearClassId==7){
            subjectsQueryWrapper.in("id",1,2,4);
        }else if (yearClassId == 8){
            if ((quarterNum == 2 || quarterNum == 1) || examNum == 1){
                subjectsQueryWrapper.in("id",1,2,3,4);
            }else {
                subjectsQueryWrapper.in("id",1,2,4);
            }
            //秋季班的上个学期期末
            //subjectsQueryWrapper.in("id",1,2,4);//没有物理
        }
        List<Subjects> subjectsList = this.list(subjectsQueryWrapper);
        return subjectsList;
    }

}
